package com.wasu.sdk_ott.http.network.interceptor;


import android.util.Log;

import com.wasu.UILApplication;
import com.wasu.constant.Config;
import com.wasu.sdk_ott.utils.WasuTvModelUtil;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * @date 2020/4/7 12:51
 * @create ltx
 * @description
 */
public class HeadInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        String x_prod_type = "DVB";
        if(WasuTvModelUtil.isbIpMode()){
            x_prod_type= "IPTV";
        }
        Request request = chain.request()
                .newBuilder()
                .addHeader("X-TERMINAL-MODEL", Config.readDvbOttModel())
                .addHeader("X-TERMINAL-ID", WasuTvModelUtil.wasu_bsa_getTvid())
                .addHeader("X-REGION", Config.getRegion())
                .addHeader("X-USER-ID", Config.sUserId)
                .addHeader("X-REGION-ID","")
                .addHeader("X-MAC", Config.wasu_bsa_getMacEth0())
                .addHeader("X-USERPROFILE", Config.sUserProfile)
                .addHeader("referer", "http://hd2.hzdtv.tv/4KProject.html")
                .addHeader("User-agent", WasuTvModelUtil.getWasuUserAgent(UILApplication.getInstance().getApplication()))
                .addHeader("X-PROD-TYPE",x_prod_type)
                .build();
        Log.e("module_http", request.headers().toString() + "");
        return chain.proceed(request);
    }
}
